#include <channel-service/channel_service.hpp>
#include <channel-client/channel_client.hpp>
#include <fas/mux/best_mux.hpp>

namespace am = ::fas::mux;

struct test
  : fasys::client::channel::iclient_callback
{
  void process(::fasys::api::subscribe_response& cmd)
  {
    std::cout << "::fasys::client::channel::subscribe" << std::endl;
  }

  void process(::fasys::api::message_notify& cmd)
  {
    std::cout << "::fasys::client::channel::message" << std::endl;
  }
};

int main()
{
  using namespace fasys::api;
  using namespace fasys::service::channel;
  using namespace fasys::client::channel;
  channel_service cs;
  channel_client cc;
  test t;
  cc.callback(&t);
  am::best_mux mux;
  cs.start(&mux, server_config() );
  cc.start(&mux, client_config() );
  ::fasys::api::subscribe_request s;
  s.channel = "channel_1";
  s.timeout = 10;
  ::fasys::api::message_publish m;
  m.channel = "channel_1";
  cc.send(m);
  cc.send(s);
  cc.send(m);
  cc.send(m);
  for (;;)
    mux.select(-1);
  return 0;
}